﻿@model IEnumerable<KhoaLuan.Areas.Admin.Models.ReportInfo>


<h2 style="color:red;">@ViewBag.Title</h2>

@using (Html.BeginForm("SearchProduct", "ThongKe"))
{
    <fieldset>
        <legend>Thời gian</legend>
        Từ Năm :<input id="Min" name="Min" type="text"  class="form-control" style="width:200px;">
        Tới: <input id="Max" name="Max" type="text" class="form-control" style="width:200px;">
        <br/>
        <input class="btn btn-success" type="submit" value="Search" />
    </fieldset>
}
<hr />

<div>
    <div class="col-md-2"></div>
    <div class="col-md-8">

        <script type="text/javascript" src="https://www.google.com/jsapi"></script>
        <script type="text/javascript">
    google.load("visualization", "1", { packages: ["corechart"] });
    google.setOnLoadCallback(drawChart);
    function drawChart() {

        var data = google.visualization.arrayToDataTable([
          ['Nhóm', 'Giá trị'],
          @foreach (var r in Model)
          {
              <text>["@r.Group", @r.Count],</text>
          }
        ]);

        var options = {
            title: 'Thống Kê Doanh Số'
        };

        var chart = new google.visualization.PieChart(document.getElementById('piechart'));

        chart.draw(data, options);
    }
        </script>
        <div id="piechart" style="width: 900px; height: 500px;"></div>
    </div>
</div>


<table class="table table-hover">
    <tr>
        <th>@ViewBag.Group</th>
        <th>Doanh số</th>
        <th>Tổng số lượng</th>
        <th>Giá thấp nhất</th>
        <th>Giá cao nhất</th>
        <th>Giá trung bình</th>
    </tr>
    @foreach (var r in Model)
    {
        <tr>
            <td>@r.Group</td>
            <td>@r.Sum</td>
            <td>@r.Count</td>
            <td>@r.Min</td>
            <td>@r.Max</td>
            <td>@r.Avg</td>
        </tr>
    }
</table>

@section scripts{

<script src="~/jquery-ui/jquery-ui.min.js"></script>
<link href="~/jquery-ui/jquery-ui.min.css" rel="stylesheet" />
    <script>
        $(function () {
            $("fieldset #Min, fieldset #Max").datepicker({
                dateFormat: 'yy-mm-dd'
            });
        });
    </script>


}